package com.roomio.dao.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.roomio.core.dao.impl.GenericJPADAO;
import com.roomio.core.security.model.User;
import com.roomio.dao.TransactionsDAO;
import com.roomio.dao.UserInfoDAO;
import com.roomio.domain.Transaction;

@Repository
public class TransactionsDAOImpl extends GenericJPADAO<Transaction, Long> implements TransactionsDAO {
	@Autowired
	private UserInfoDAO userInfoDao;

	@Override
	public List<Transaction> getTransactionByUserName(String userName) {
		User user = userInfoDao.findUserByEmail(userName);
		return findByNamedQuery("user.transaction.by.user", new String[]{"userId"}, new Object[]{user.getId()});
	}

	@Override
	public List<Transaction> getTransactionByGroup(Long groupId) {
		return findByNamedQuery("group.transaction.by.groupid", new String[]{"groupId"}, new Object[]{groupId});
	}

	
	
	
	
}